//
//  CourseClassInfoView.m
//  fitnessmanage
//
//  Created by wujian on 2017/10/22.
//  Copyright © 2017年 zongquankeji. All rights reserved.
//

#import "CourseClassInfoView.h"
#import "UIButton+Mybutton.h"

@interface CourseClassInfoView()<UICollectionViewDelegate,UICollectionViewDataSource>{
    
    NSArray<NSString *> *activities;
}

@property(nonatomic,strong)NSMutableArray *courseDetailViewArray;

@property(nonatomic,strong)NSMutableArray *userCommentViewArray;

@end

@implementation CourseClassInfoView

-(id)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        UIScrollView *scrollView = [[UIScrollView alloc] init];
        scrollView.backgroundColor = CSWhiteColor;
        scrollView.showsVerticalScrollIndicator = NO;
        [self addSubview:scrollView];
        self.scrollView = scrollView;
        
        /**
         封面图片
         */
        SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero imageURLStringsGroup:@[PlaceHold,PlaceHold,PlaceHold]];
        cycleScrollView.pageControlStyle = SDCycleScrollViewPageContolStyleClassic;
        cycleScrollView.infiniteLoop = NO;
        cycleScrollView.autoScroll = NO;
        cycleScrollView.placeholderImage = PlaceHold;
        //cycleScrollView.currentPageDotColor = CSWhiteColor;
        cycleScrollView.pageDotColor = BackGroundColor;
        //cycleScrollView.imageURLStringsGroup =
        [scrollView addSubview:cycleScrollView];
        self.cycleScrollView = cycleScrollView;
        
        /**
         编辑封面图片按钮
         */
        UIButton *editBtn = [[UIButton alloc] init];
        [editBtn setTitle:@"编辑封面图片"];
        editBtn.titleLabel.font = MidFont;
        [editBtn setTitleColor:CSColorFromRGB(0xfefefe)];
        editBtn.contentEdgeInsets = UIEdgeInsetsMake(10, 15, 10, 15);
        [editBtn setBackgroundColor:[CSBlackColor colorWithAlphaComponent:0.2]];
        [scrollView addSubview:editBtn];
        self.editBtn = editBtn;
        
        /**
         课程名字
         */
        UILabel *courseLabel = [[UILabel alloc] init];
        courseLabel.font = TitleBoldFont;
        courseLabel.text = @"哈达瑜伽";
        [scrollView addSubview:courseLabel];
        self.courseLabel = courseLabel;
        
        /**
         评论详情View
         */
        CommentLineInfoView *commentLineInfoView = [[CommentLineInfoView alloc] init];
        [scrollView addSubview:commentLineInfoView];
        self.commentLineInfoView = commentLineInfoView;
        
        /**
         线条
         */
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = BackGroundColor;
        [scrollView addSubview:lineView];
        self.lineView = lineView;
        
        /**
         时间
         */
        InfoView *timeInfoView = [[InfoView alloc] init];
        timeInfoView.titleImageView.image = [UIImage imageNamed:@"courseshare_icon_time"];
        timeInfoView.titleLabel.text = @"暂无数据";
        timeInfoView.detailLabel.text = @"课程时间";
        [scrollView addSubview:timeInfoView];
        self.timeInfoView = timeInfoView;
        
        /**
         教室
         */
        InfoView *roomInfoView = [[InfoView alloc] init];
        roomInfoView.titleImageView.image = [UIImage imageNamed:@"courseshare_icon_room"];
        roomInfoView.titleLabel.text = @"暂无数据";
        roomInfoView.detailLabel.text = @"上课教室";
        [scrollView addSubview:roomInfoView];
        self.roomInfoView = roomInfoView;;
        
        /**
         地点
         */
        InfoView *placeInfoView = [[InfoView alloc] init];
        placeInfoView.titleImageView.image = [UIImage imageNamed:@"courseshare_icon_adress"];
        placeInfoView.titleLabel.text = @"暂无数据";
        placeInfoView.detailLabel.text = @"课程地点";
        [scrollView addSubview:placeInfoView];
        self.placeInfoView = placeInfoView;
                
        /**
         线条
         */
        UIView *lineView1 = [[UIView alloc] init];
        lineView1.backgroundColor = BackGroundColor;
        [scrollView addSubview:lineView1];
        self.lineView1 = lineView1;
        
        /**
         教练名字
         */
        UILabel *coachLineLabel = [[UILabel alloc] init];
        coachLineLabel.backgroundColor = ButtonBackGroundColor;
        [scrollView addSubview:coachLineLabel];
        self.coachLineLabel = coachLineLabel;
        
        
        /**
         教练名字
         */
        UILabel *coachNameLabel = [[UILabel alloc] init];
        coachNameLabel.font = TitleBoldFont;
        coachNameLabel.text = @"教练";
        [scrollView addSubview:coachNameLabel];
        self.coachNameLabel = coachNameLabel;
        
        /**
         CollectionView
         */
        UICollectionViewFlowLayout *collectViewFlowLayout = [[UICollectionViewFlowLayout alloc] init];
        collectViewFlowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        //设置cell之间间距
        collectViewFlowLayout.minimumInteritemSpacing = 10;
        //设置行距
        collectViewFlowLayout.minimumLineSpacing = 0;
        
        collectViewFlowLayout.sectionInset = UIEdgeInsetsMake(0, 10, 0, 10);
        
        CGFloat itemWith = 150.0f;
        
        //设置Item大小
        collectViewFlowLayout.itemSize = CGSizeMake(itemWith, itemWith);
        UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectZero collectionViewLayout:collectViewFlowLayout];
        collectionView.showsHorizontalScrollIndicator = NO;
        collectionView.showsVerticalScrollIndicator = NO;
        collectionView.backgroundColor = CSWhiteColor;
        collectionView.delegate = self;
        collectionView.dataSource = self;
        [collectionView registerClass:[ClassCoachCollectionViewCell class] forCellWithReuseIdentifier:@"ClassCoachCollectionViewCell"];
        [scrollView addSubview:collectionView];
        self.collectionView = collectionView;
        
        /**
         线条
         */
        UIView *lineView2 = [[UIView alloc] init];
        lineView2.backgroundColor = BackGroundColor;
        [scrollView addSubview:lineView2];
        self.lineView2 = lineView2;
        
        /**
         课程介绍View
         */
        UILabel *courseLineLabel = [[UILabel alloc] init];
        courseLineLabel.backgroundColor = ButtonBackGroundColor;
        [scrollView addSubview:courseLineLabel];
        self.courseLineLabel = courseLineLabel;
        
        /**
         课程介绍
         */
        UILabel *courseIntroduceLabel = [[UILabel alloc] init];
        courseIntroduceLabel.font =  TitleBoldFont;
        courseIntroduceLabel.text = @"课程介绍";
        [scrollView addSubview:courseIntroduceLabel];
        self.courseIntroduceLabel = courseIntroduceLabel;
        
        //UIButton *editCourseBtn;
        UIButton *editCourseBtn = [[UIButton alloc] init];
        [editCourseBtn setTitle:@"编辑课程介绍"];
        editCourseBtn.titleLabel.font = MidFont;
        [editCourseBtn setTitleColor:CSColorFromRGB(0x999999)];
        [scrollView addSubview:editCourseBtn];
        self.editCourseBtn = editCourseBtn;
        
        /**
         课程时间
         */
        UILabel *courseTimeLabel = [[UILabel alloc] init];
        courseTimeLabel.text = @"0";
        courseTimeLabel.font = [UIFont boldSystemFontOfSize:26.0];
        courseTimeLabel.textColor = CSColorFromRGB(0x3b3b3b);
        courseTimeLabel.textAlignment = NSTextAlignmentCenter;
        [scrollView addSubview:courseTimeLabel];
        self.courseTimeLabel = courseTimeLabel;
        
        /**
         课程时间1
         */
        UILabel *courseTimeLabel1 = [[UILabel alloc] init];
        courseTimeLabel1.text = @"分钟";
        courseTimeLabel1.font = MidFont;
        courseTimeLabel1.textColor = CSColorFromRGB(0x808080);
        courseTimeLabel1.textAlignment = NSTextAlignmentCenter;
        [scrollView addSubview:courseTimeLabel1];
        self.courseTimeLabel1 = courseTimeLabel1;
        
        /**
         课程消耗
         */
        UILabel *courseExpendLabel = [[UILabel alloc] init];
        courseExpendLabel.text = @"0";
        courseExpendLabel.font = [UIFont boldSystemFontOfSize:26.0];;
        courseExpendLabel.textColor = CSColorFromRGB(0x3b3b3b);
        courseExpendLabel.textAlignment = NSTextAlignmentCenter;
        [scrollView addSubview:courseExpendLabel];
        self.courseExpendLabel = courseExpendLabel;
        
        /**
         课程消耗
         */
        UILabel *courseExpendLabel1 = [[UILabel alloc] init];
        courseExpendLabel1.text = @"千卡";
        courseExpendLabel1.font = MidFont;
        courseExpendLabel1.textColor = CSColorFromRGB(0x808080);
        courseExpendLabel1.textAlignment = NSTextAlignmentCenter;
        [scrollView addSubview:courseExpendLabel1];
        self.courseExpendLabel1 = courseExpendLabel1;;
        
        
        /**
         课程等级
         */
        UILabel *courseExpendLevel = [[UILabel alloc] init];
        courseExpendLevel.text = @"初级";
        courseExpendLevel.font = [UIFont boldSystemFontOfSize:26.0];
        courseExpendLevel.textColor = CSColorFromRGB(0x3b3b3b);
        courseExpendLevel.textAlignment = NSTextAlignmentCenter;
        [scrollView addSubview:courseExpendLevel];
        self.courseExpendLevel = courseExpendLevel;
        
        /**
         课程等级
         */
        UILabel *courseExpendLevel1 = [[UILabel alloc] init];
        courseExpendLevel1.text = @"难度";
        courseExpendLevel1.font = MidFont;
        courseExpendLevel1.textColor = CSColorFromRGB(0x808080);
        courseExpendLevel1.textAlignment = NSTextAlignmentCenter;
        [scrollView addSubview:courseExpendLevel1];
        self.courseExpendLevel1 = courseExpendLevel1;;
        
        
        /**
         雷达图
         */
//        activities = @[ @"协调", @"力量", @"消耗", @"柔韧", @"心肺" ];
//
//        _chartView = [[RadarChartView alloc] init];
//        _chartView.delegate = self;
//        _chartView.chartDescription.enabled = NO;
//        _chartView.webLineWidth = 1.0;
//        _chartView.innerWebLineWidth = 1.0;
//        _chartView.webColor = UIColor.lightGrayColor;
//        _chartView.innerWebColor = UIColor.lightGrayColor;
//        _chartView.webAlpha = 1.0;
//
//        ChartXAxis *xAxis = _chartView.xAxis;
//        xAxis.labelFont = MidFont;//[UIFont fontWithName:@"PingFang-SC-Medium" size:14.f];
//        xAxis.xOffset = 0.0;
//        xAxis.yOffset = 0.0;
//        xAxis.valueFormatter = self;
//        xAxis.labelTextColor = CSColorFromRGB(0x333333);
//
//        ChartYAxis *yAxis = _chartView.yAxis;
//        yAxis.labelFont = MidFont;//[UIFont fontWithName:@"HelveticaNeue-Light" size:9.f];
//        yAxis.labelCount = 5;
//        yAxis.axisMinimum = 0.0;
//        yAxis.axisMaximum = 80.0;
//        yAxis.drawLabelsEnabled = NO;
//        _chartView.legend.enabled = NO; //不显示图例
//        [scrollView addSubview:_chartView];
        

        /**
         约课流程
         */
        UILabel *classProgressLine = [[UILabel alloc] init];
        classProgressLine.backgroundColor = ButtonBackGroundColor;
        [scrollView addSubview:classProgressLine];
        self.classProgressLine = classProgressLine;

        /**
         约课流程
         */
        UILabel *classProgress  = [[UILabel alloc] init];
        classProgress.font =  TitleBoldFont;;
        classProgress.text = @"约课流程";
        [scrollView addSubview:classProgress];
        self.classProgress = classProgress;;
        
        /**
         线条
         */
        UIView *lineView3 = [[UIView alloc] init];
        lineView3.backgroundColor = BackGroundColor;
        [scrollView addSubview:lineView3];
        self.lineView3 = lineView3;

        /**
         约课按钮
         */
        UIButton *classBtn = [[UIButton alloc] init];
        [classBtn setTitle:@"1.约课"];
        [classBtn setImage:@"courseshare_icon_appointment_aptm"];
        [classBtn setTitleColor:CSColorFromRGB(0x666666)];
        classBtn.titleLabel.font = [UIFont systemFontOfSize:13.0];
        [scrollView addSubview:classBtn];
        self.classBtn = classBtn;


        /**
         扫码按钮
         */
        UIButton *scanBtn = [[UIButton alloc] init];
        [scanBtn setTitle:@"2.扫码签到"];
        [scanBtn setImage:@"courseshare_icon_appointment_code"];
        [scanBtn setTitleColor:CSColorFromRGB(0x666666)];
        scanBtn.titleLabel.font = [UIFont systemFontOfSize:13.0];
        [scrollView addSubview:scanBtn];
        self.scanBtn = scanBtn;


        /**
         评价按钮
         */
        UIButton *commentBtn = [[UIButton alloc] init];
        [commentBtn setTitle:@"3.评价"];
        [commentBtn setImage:@"courseshare_icon_appointment_evaluate"];
        [commentBtn setTitleColor:CSColorFromRGB(0x666666)];
        commentBtn.titleLabel.font = [UIFont systemFontOfSize:13.0];
        [scrollView addSubview:commentBtn];
        self.commentBtn = commentBtn;


        /**
         规则详情按钮
         */
        UIButton *ruleInfoBtn = [[UIButton alloc] init];
        [ruleInfoBtn setTitle:@"规则详情"];
        [ruleInfoBtn setTitleColor:CSColorFromRGB(0x999999)];
        ruleInfoBtn.titleLabel.font = MidFont;
        [scrollView addSubview:ruleInfoBtn];
        self.ruleInfoBtn = ruleInfoBtn;

        /**
         线条
         */
        UIView *lineView4 = [[UIView alloc] init];
        lineView4.backgroundColor = BackGroundColor;
        [scrollView addSubview:lineView4];
        self.lineView4 = lineView4;
        
        /**
         学员评价
         */
        UILabel *userCommentLineLabel = [[UILabel alloc] init];
        userCommentLineLabel.backgroundColor = ButtonBackGroundColor;
        [scrollView addSubview:userCommentLineLabel];
        self.userCommentLineLabel = userCommentLineLabel;
        
        /**
         学员评价
         */
        UILabel *userCommentLabel = [[UILabel alloc] init];
        userCommentLabel.font =  TitleBoldFont;
        userCommentLabel.text = @"评价";
        [scrollView addSubview:userCommentLabel];
        self.userCommentLabel = userCommentLabel;;


        /**
         全部
         */
        UIButton *userCommentAllBtn = [[UIButton alloc] init];
        [userCommentAllBtn setTitle:@"查看全部"];
        [userCommentAllBtn setTitleColor:CSColorFromRGB(0x999999)];
        userCommentAllBtn.titleLabel.font = MidFont;
        [scrollView addSubview:userCommentAllBtn];
        self.userCommentAllBtn = userCommentAllBtn;

        /**
         线条
         */
        UIView *lineView5 = [[UIView alloc] init];
        lineView5.backgroundColor = BackGroundColor;
        [scrollView addSubview:lineView5];
        self.lineView5 = lineView5;
        

        /**
         预约人数状态
         */
        UILabel *stateLabel = [[UILabel alloc] init];
        stateLabel.text  = @"剩余名额：12人";
        stateLabel.font = MidBigFont;
        stateLabel.textColor = CSColorFromRGB(0x212121);
        [scrollView addSubview:stateLabel];
        self.stateLabel = stateLabel;


        YLProgressBar *stateProgressBar = [[YLProgressBar alloc] init];
        stateProgressBar.progressTintColors = @[CSColorFromRGB(0xffdd00),CSColorFromRGB(0xff7428)];
        stateProgressBar.type                     = YLProgressBarTypeRounded;
        stateProgressBar.trackTintColor           = CSClearColor;
        stateProgressBar.trackTintColor           = CSColorFromRGB(0xf0f0f0);
        stateProgressBar.behavior                 = YLProgressBarBehaviorWaiting;
        stateProgressBar.stripesOrientation       = YLProgressBarStripesOrientationLeft;
        [scrollView addSubview:stateProgressBar];
        self.stateProgressBar = stateProgressBar;

        /**
         预约人数按钮
         */
        UIButton *stateBtn = [[UIButton alloc] init];
        [stateBtn setTitle:@"立即预约"];
        [stateBtn setTitleColor:CSColorFromRGB(0x212121)];
        stateBtn.titleLabel.font = MidBigFont;
        stateBtn.backgroundColor = ButtonBackGroundColor;
        [scrollView addSubview:stateBtn];
        self.stateBtn = stateBtn;
        
        [self setConstraints];
    }
    
    return self;
}

#pragma mark 设置约束
-(void)setConstraints{
    
    [self.scrollView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.edges.mas_equalTo(self);
    }];
    
    [self.cycleScrollView mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.left.width.mas_equalTo(self.scrollView);

        make.height.mas_equalTo(220);
    }];
    
    /**
     编辑封面图片按钮
     */
    [self.editBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.scrollView);
        make.right.mas_equalTo(self);
    }];
    
    /**
     课程名字
     */
    [self.courseLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.cycleScrollView.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.scrollView).offset(20);
    }];
    
    /**
     评论详情View
     */
    [self.commentLineInfoView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.scrollView);
        
        make.top.mas_equalTo(self.courseLabel.mas_bottom).offset(10);
    }];
    
    /**
     线条
     */
    [self.lineView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.width.mas_equalTo(self.scrollView);
        
        make.top.mas_equalTo(self.commentLineInfoView.mas_bottom).offset(10);
        
        make.height.mas_equalTo(10);
    }];
    
    /**
     时间
     */
    [self.timeInfoView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.lineView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    
    /**
     教室
     */
    [self.roomInfoView mas_remakeConstraints:^(MASConstraintMaker *make) {
    
        make.top.mas_equalTo(self.timeInfoView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];
    
    
    /**
     地点
     */
    [self.placeInfoView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.roomInfoView.mas_bottom);
        
        make.left.width.mas_equalTo(self.scrollView);
    }];

    
    /**
     线条
     */
    [self.lineView1 mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.width.mas_equalTo(self.scrollView);
        
        make.top.mas_equalTo(self.placeInfoView.mas_bottom);
        
        make.height.mas_equalTo(10);
    }];
    
    /**
     教练名字
     */
    [self.coachLineLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.lineView1.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.scrollView).offset(13);
        
        make.width.mas_equalTo(3);
        
        make.height.mas_equalTo(self.coachNameLabel);
    }];
    
    
    /**
     教练名字
     */
    [self.coachNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.lineView1.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.coachLineLabel.mas_right).offset(7);
        
    }];

    [self.collectionView mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.coachNameLabel.mas_bottom).offset(20);
        
        make.left.width.mas_equalTo(self.scrollView);
        
        make.height.mas_equalTo(150);
    }];
    
    /**
     线条
     */
    [self.lineView2 mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.collectionView.mas_bottom).offset(20);

        make.left.width.mas_equalTo(self.scrollView);

        make.height.mas_equalTo(10);
    }];
    
    
    /**
     课程介绍View
     */
    [self.courseLineLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.lineView2.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.scrollView).offset(13);
        
        make.width.mas_equalTo(3);
        
        make.height.mas_equalTo(self.courseIntroduceLabel);
    }];
    
    /**
     课程介绍
     */
    [self.courseIntroduceLabel mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.lineView2.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.courseLineLabel.mas_right).offset(7);
    }];
    
    [self.editCourseBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.right.mas_equalTo(self).offset(-20);
        
        make.centerY.mas_equalTo(self.courseIntroduceLabel);
    }];
    
    /**
     课程时间
     */
    [self.courseTimeLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.mas_equalTo(self.courseLineLabel);
        
        make.top.mas_equalTo(self.courseIntroduceLabel.mas_bottom).offset(30);
    }];
    
    
    /**
     课程时间1
     */
    [self.courseTimeLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.courseTimeLabel.mas_bottom).offset(10);
        make.left.width.mas_equalTo(self.courseTimeLabel);
    }];
    
    /**
     课程消耗
     */
    [self.courseExpendLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.width.height.mas_equalTo(self.courseTimeLabel);
        make.left.mas_equalTo(self.courseTimeLabel.mas_right);
    }];
    
    /**
     课程消耗
     */
    [self.courseExpendLabel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.courseExpendLabel.mas_bottom).offset(10);
        make.left.width.mas_equalTo(self.courseExpendLabel);
    }];
    
    
    /**
     课程等级
     */
    [self.courseExpendLevel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.width.height.mas_equalTo(self.courseExpendLabel);
        make.left.mas_equalTo(self.courseExpendLabel.mas_right);
        make.right.mas_equalTo(self).offset(-13);
    }];
    
    /**
     课程等级
     */
    [self.courseExpendLevel1 mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.courseExpendLevel.mas_bottom).offset(10);
        make.left.width.mas_equalTo(self.courseExpendLevel);
    }];
    
    UIView *tmpView;
    
    if (self.courseDetailViewArray.count > 0) {
        
        for (UIView *view in self.courseDetailViewArray) {
            
            [view mas_remakeConstraints:^(MASConstraintMaker *make) {
               
                if (tmpView) {
                    
                    make.top.mas_equalTo(tmpView.mas_bottom).offset(30);
                }
                else{
                    
                    make.top.mas_equalTo(_courseExpendLevel.mas_bottom).offset(30);
                }
                
                make.left.mas_equalTo(self.scrollView).offset(15);
                
                make.right.mas_equalTo(self).offset(-15);
                
                if ([view isKindOfClass:[UIImageView class]]) {
                    
                    make.height.mas_equalTo(300);
                }
            }];
            
            tmpView = view;
        }
    }
    
    /**
     线条
     */
    [self.lineView3 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.width.mas_equalTo(self.scrollView);
        
        if (tmpView) {
            
            make.top.mas_equalTo(tmpView.mas_bottom).offset(20);
        }
        else{
            
            make.top.mas_equalTo(self.courseExpendLevel.mas_bottom).offset(20);
        }
        make.height.mas_equalTo(10);
    }];
    
    /**
     约课流程
     */
    [self.classProgressLine mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.lineView3.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.scrollView).offset(13);
        
        make.width.mas_equalTo(3);
        
        make.height.mas_equalTo(self.classProgress);
        
    }];
    
    
    /**
     约课流程
     */
    [self.classProgress mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.lineView3.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.classProgressLine.mas_right).offset(7);
    }];


    /**
     约课按钮
     */

    CGFloat width = (kScreenWidth -30)/ 3.0;

    [self.classBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.classProgress.mas_bottom).offset(15);

        make.left.mas_equalTo(self.scrollView).offset(15);

        make.width.mas_equalTo(width);
    }];


    /**
     扫码按钮
     */
    [self.scanBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.classBtn);

        make.left.mas_equalTo(self.classBtn.mas_right);

        make.width.mas_equalTo(width);
    }];


    /**
     评价按钮
     */
    [self.commentBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.classBtn);

        make.left.mas_equalTo(self.scanBtn.mas_right);

        make.width.mas_equalTo(width);
    }];


    /**
     规则详情按钮
     */
    [self.ruleInfoBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.centerY.mas_equalTo(self.classProgress);

        make.right.mas_equalTo(self.mas_right).offset(-20);
        
    }];
    

    /**
     线条
     */
    [self.lineView4 mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.left.width.mas_equalTo(self.scrollView);
        
        make.top.mas_equalTo(self.commentBtn.mas_bottom).offset(18);
        
        make.height.mas_equalTo(10);
    }];
    
    /**
     学员评价
     */
    [self.userCommentLineLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.top.mas_equalTo(self.lineView4.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.scrollView).offset(7);
        
        make.width.mas_equalTo(3);
        
        make.height.mas_equalTo(self.userCommentLabel);
    }];
    
    /**
     学员评价
     */
    [self.userCommentLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.lineView4.mas_bottom).offset(20);
        
        make.left.mas_equalTo(self.userCommentLineLabel.mas_right).offset(7);
        
        make.height.mas_equalTo(self.userCommentLineLabel);
    }];
    

    /**
     全部
     */
    [self.userCommentAllBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.centerY.mas_equalTo(self.userCommentLabel);
        
        make.right.mas_equalTo(self).offset(-20);
    }];
    
    UserCommentView *tmpCpmmentView;
    
    for (UserCommentView *commentView in self.userCommentViewArray) {
        
        [commentView mas_remakeConstraints:^(MASConstraintMaker *make) {
           
            if (tmpCpmmentView) {
                
                make.top.mas_equalTo(tmpCpmmentView.mas_bottom);
            }
            else{
                
                make.top.mas_equalTo(self.userCommentLabel.mas_bottom).offset(30);
            }
            
            make.left.width.mas_equalTo(self);
        }];
        
        tmpCpmmentView = commentView;
    }

    /**
     线条
     */
    [self.lineView5 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.width.mas_equalTo(self.scrollView);
        
        if (tmpCpmmentView) {
            
            make.top.mas_equalTo(tmpCpmmentView.mas_bottom);
        }
        else{
            
            make.top.mas_equalTo(self.userCommentLabel.mas_bottom).offset(20);
        }
        
        make.height.mas_equalTo(10);
    }];
    

    /**
     预约人数状态
     */
    [self.stateLabel mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.left.mas_equalTo(self.scrollView).offset(13);

        make.top.mas_equalTo(self.lineView5.mas_bottom).offset(15);
    }];


    [self.stateProgressBar mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.top.mas_equalTo(self.stateLabel.mas_bottom).offset(10);

        make.left.mas_equalTo(self.stateLabel);

        make.width.mas_equalTo(120);

        make.height.mas_equalTo(8);
    }];

    /**
     预约人数按钮
     */
    [self.stateBtn mas_remakeConstraints:^(MASConstraintMaker *make) {

        make.right.mas_equalTo(self);

        make.top.mas_equalTo(self.lineView5.mas_bottom);

        make.height.mas_equalTo(60);

        make.width.mas_equalTo(150);
    }];
//
    //自己设置数据
    [self setChartData];
    
    [self setNeedsLayout];
    
    [self layoutIfNeeded];
//
    self.scrollView.contentSize = CGSizeMake(self.width, self.stateBtn.bottom + adaptNavagationBar);
    
}

#pragma mark UICollectionViewDataSource
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    
    return 0;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    ClassCoachCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ClassCoachCollectionViewCell" forIndexPath:indexPath];
    
    return cell;
}


/**
 设置雷达数据
 */
- (void)setChartData
{
//    double mult = 80;
//    double min = 20;
//    int cnt = 5;
//
//    NSMutableArray *entries1 = [[NSMutableArray alloc] init];
//
//    // NOTE: The order of the entries when being added to the entries array determines their position around the center of the chart.
//    for (int i = 0; i < cnt; i++)
//    {
//        [entries1 addObject:[[RadarChartDataEntry alloc] initWithValue:(arc4random_uniform(mult) + min)]];
//    }
//
//    RadarChartDataSet *set1 = [[RadarChartDataSet alloc] initWithValues:entries1 label:@"Last Week"];
//    [set1 setColor:ButtonBackGroundColor];
//    set1.fillColor = ButtonBackGroundColor;
//    set1.drawFilledEnabled = YES;
//    set1.fillAlpha = 0.7;
//    set1.lineWidth = 2.0;
//    set1.drawHighlightCircleEnabled = YES;
//    [set1 setDrawHighlightIndicators:NO];
//
//    RadarChartData *data = [[RadarChartData alloc] initWithDataSets:@[set1]];
//    [data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:16.f]];
//    [data setDrawValues:NO];
//    data.valueTextColor = CSColorFromRGB(0x333333);
//
//    _chartView.data = data;
//
//    /**
//     课程等级
//     */
//    [_chartView mas_remakeConstraints:^(MASConstraintMaker *make) {
//        make.centerX.mas_equalTo(self.scrollView);
//        make.top.mas_equalTo(self.courseExpendLevel1.mas_bottom).offset(30);
//        make.width.height.mas_equalTo(200);
//    }];
//
}



#pragma mark 设置课程详情图片和文字
-(void)setCourseDetailArray:(NSMutableArray *)courseDetailArray{
    
    TTTAttributedLabel *label = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];
    label.numberOfLines = 0;
    label.lineBreakMode = NSLineBreakByCharWrapping;
    label.font = MidFont;
    label.textColor = CSColorFromRGB(0x999999);
    label.lineSpacing = 5;
    label.text = @"哈达瑜伽室目前世界上最为盛行的瑜伽\n这种以调息与体位法为中心的体动瑜伽的体动瑜伽的体动瑜伽的体动瑜伽的体动瑜伽的体动瑜伽的体动瑜伽的体动瑜伽的体动瑜伽的体动瑜伽的体动瑜伽";
    [_scrollView addSubview:label];
    [self.courseDetailViewArray addObject:label];
    
    UIImageView *titleImageView = [[UIImageView alloc] init];
    titleImageView.contentMode = UIViewContentModeScaleAspectFill;
    titleImageView.layer.masksToBounds = YES;
    [titleImageView sd_setImageWithURL:[NSURL URLWithString:@"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1508758695055&di=d80a70f36dfb9adce51a5abe76539f2f&imgtype=0&src=http%3A%2F%2Fimgsrc.baidu.com%2Fimage%2Fc0%253Dshijue1%252C0%252C0%252C294%252C40%2Fsign%3D0e6abecc5ee736d14c1e844bf33925b7%2F2e2eb9389b504fc263064015efdde71190ef6d41.jpg"]];
    [_scrollView addSubview:titleImageView];
    [self.courseDetailViewArray addObject:titleImageView];
    
    [self setConstraints];
}

-(void)setUserCommentArray:(NSMutableArray *)userCommentArray{
    
    for (int i = 0; i < 3; i ++) {
    
        UserCommentView *commentView  = [[UserCommentView alloc] init];
        [self.scrollView addSubview:commentView];
        [self.userCommentViewArray addObject:commentView];
    }
        
    [self setConstraints];
}

-(void)layoutSubviews{
    
    /**
     约课按钮
     */
    
    [self.classBtn titleBelowTheImageWithSpace:5];
    
    
    /**
     扫码按钮
     */
    [self.scanBtn titleBelowTheImageWithSpace:5];
    
    
    /**
     评价按钮
     */
    [self.commentBtn titleBelowTheImageWithSpace:5];

    /**
     规则详情按钮
     */
    [self.ruleInfoBtn titleBelowTheImageWithSpace:5];
}

#pragma mark - IAxisValueFormatter
//- (NSString *)stringForValue:(double)value
//                        axis:(ChartAxisBase *)axis
//{
//    return activities[(int) value % activities.count];
//}


#pragma mark Get
-(NSMutableArray *)courseDetailViewArray{
    
    if(!_courseDetailViewArray){
        
        _courseDetailViewArray = [[NSMutableArray alloc] init];
    }
    
    return _courseDetailViewArray;
}

-(NSMutableArray *)userCommentViewArray{
    
    if (!_userCommentViewArray) {
        
        
        _userCommentViewArray = [[NSMutableArray alloc] init];
    }
    
    return _userCommentViewArray;
}
@end
